package org.cis.jproyinv.seguridad.vista;

import java.awt.Color;
import java.util.Date;
import javax.swing.DefaultListModel;
import javax.swing.JOptionPane;
import org.cis.jproyinv.comun.modelo.Direccion;
import org.cis.jproyinv.comun.modelo.EstadoCivil;
import org.cis.jproyinv.comun.modelo.TipoDocumentoIdentificacion;
import org.cis.jproyinv.comun.modelo.TipoGenero;
import org.cis.jproyinv.seguridad.modelo.EstadoLaboral;
import org.cis.jproyinv.seguridad.modelo.Rol;
import org.cis.jproyinv.seguridad.modelo.Usuario;
import org.cis.jproyinv.seguridad.negocio.AdministrarUsuarioUCController;

public class EditarUsuario extends javax.swing.JDialog {

    AdministrarUsuarioUCController usuarioUCC = new AdministrarUsuarioUCController();
    DefaultListModel rolesUsuario = new DefaultListModel();
    DefaultListModel rolesDisponibles = new DefaultListModel();
    boolean contraseñaCorrecta = false;
    boolean editar = false;

    public EditarUsuario(boolean bandera, Usuario usuario, AdministrarUsuarioUCController controlador) {
        super(new javax.swing.JFrame(), true);
        initComponents();
        btnRemover.setEnabled(false);
        btnAgregar.setEnabled(true);
        this.setLocationRelativeTo(this);
        this.dtcFechaNacimiento.setDate(new Date());
        this.usuarioUCC = controlador;
        editar = bandera;
        if (editar == true) {
            this.usuarioUCC.setUsuario(usuario);
            reemplazarCampos(usuarioUCC.getUsuario());
        }else{
            txtDNI.setEditable(true);
        }
        cargarRoles(editar);
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        bindingGroup = new org.jdesktop.beansbinding.BindingGroup();

        jComboBox1 = new javax.swing.JComboBox();
        tabbedPaneVertical1 = new org.edisoncor.gui.tabbedPane.TabbedPaneVertical();
        panelImage3 = new org.edisoncor.gui.panel.PanelImage();
        panelRound1 = new org.edisoncor.gui.panel.PanelRound();
        txtNombreUsuario = new org.edisoncor.gui.textField.TextFieldRound();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        lblContraseñaConfirmacion = new javax.swing.JLabel();
        txtContrasenia1 = new org.edisoncor.gui.passwordField.PasswordFieldRound();
        txtContraseniaConfirmacion1 = new org.edisoncor.gui.passwordField.PasswordFieldRound();
        btnDisponibilidad = new javax.swing.JButton();
        panelImage2 = new org.edisoncor.gui.panel.PanelImage();
        panelRound2 = new org.edisoncor.gui.panel.PanelRound();
        jLabel21 = new javax.swing.JLabel();
        txtTituloAcademico = new org.edisoncor.gui.textField.TextFieldRound();
        cbxEstadoLaboral = new javax.swing.JComboBox();
        jLabel22 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        panelRound3 = new org.edisoncor.gui.panel.PanelRound();
        txtNombres = new org.edisoncor.gui.textField.TextFieldRound();
        cbxTipoDNI = new javax.swing.JComboBox();
        txtDNI = new org.edisoncor.gui.textField.TextFieldRound();
        jLabel7 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        jLabel17 = new javax.swing.JLabel();
        jLabel18 = new javax.swing.JLabel();
        cbxGenero = new javax.swing.JComboBox();
        txtApellidos = new org.edisoncor.gui.textField.TextFieldRound();
        jLabel19 = new javax.swing.JLabel();
        jLabel20 = new javax.swing.JLabel();
        jLabel23 = new javax.swing.JLabel();
        txtEmail = new org.edisoncor.gui.textField.TextFieldRound();
        jLabel24 = new javax.swing.JLabel();
        cbxEstadoCivil = new javax.swing.JComboBox();
        dtcFechaNacimiento = new com.toedter.calendar.JDateChooser();
        panelImage5 = new org.edisoncor.gui.panel.PanelImage();
        panelRound4 = new org.edisoncor.gui.panel.PanelRound();
        txtPais = new org.edisoncor.gui.textField.TextFieldRound();
        txtCiudad = new org.edisoncor.gui.textField.TextFieldRound();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        txtProvincia = new org.edisoncor.gui.textField.TextFieldRound();
        txtCelular = new org.edisoncor.gui.textField.TextFieldRound();
        txtTelefono = new org.edisoncor.gui.textField.TextFieldRound();
        txtNumeroConstruccion = new org.edisoncor.gui.textField.TextFieldRound();
        jLabel11 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        txtObservaciones = new javax.swing.JTextArea();
        txtCalles = new org.edisoncor.gui.textField.TextFieldRound();
        jLabel12 = new javax.swing.JLabel();
        panelImage4 = new org.edisoncor.gui.panel.PanelImage();
        jScrollPane5 = new javax.swing.JScrollPane();
        lstRolesDisponibles = new javax.swing.JList();
        jScrollPane6 = new javax.swing.JScrollPane();
        lstRolesUsuario = new javax.swing.JList();
        jLabel27 = new javax.swing.JLabel();
        jLabel28 = new javax.swing.JLabel();
        btnAgregar = new javax.swing.JButton();
        btnRemover = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        txtDescripcion = new javax.swing.JTextArea();
        btnGuardar = new javax.swing.JButton();
        btnCancelar = new javax.swing.JButton();

        jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        jComboBox1.setName("jComboBox1"); // NOI18N

        setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(jproyinv.JproyinvApp.class).getContext().getResourceMap(EditarUsuario.class);
        setTitle(resourceMap.getString("Form.title")); // NOI18N
        setAlwaysOnTop(true);
        setMinimumSize(new java.awt.Dimension(559, 370));
        setName("Form"); // NOI18N
        setResizable(false);

        tabbedPaneVertical1.setName("tabbedPaneVertical1"); // NOI18N

        panelImage3.setIcon(resourceMap.getIcon("panelImage3.icon")); // NOI18N
        panelImage3.setName("panelImage3"); // NOI18N

        panelRound1.setName("panelRound1"); // NOI18N

        txtNombreUsuario.setName("txtNombreUsuario"); // NOI18N
        txtNombreUsuario.setOpaque(true);

        jLabel4.setFont(resourceMap.getFont("jLabel4.font")); // NOI18N
        jLabel4.setForeground(resourceMap.getColor("jLabel4.foreground")); // NOI18N
        jLabel4.setText(resourceMap.getString("jLabel4.text")); // NOI18N
        jLabel4.setName("jLabel4"); // NOI18N

        jLabel5.setFont(resourceMap.getFont("jLabel4.font")); // NOI18N
        jLabel5.setForeground(resourceMap.getColor("jLabel5.foreground")); // NOI18N
        jLabel5.setText(resourceMap.getString("jLabel5.text")); // NOI18N
        jLabel5.setName("jLabel5"); // NOI18N

        jLabel6.setFont(resourceMap.getFont("jLabel4.font")); // NOI18N
        jLabel6.setForeground(resourceMap.getColor("jLabel6.foreground")); // NOI18N
        jLabel6.setText(resourceMap.getString("jLabel6.text")); // NOI18N
        jLabel6.setName("jLabel6"); // NOI18N

        lblContraseñaConfirmacion.setFont(resourceMap.getFont("lblContraseñaConfirmacion.font")); // NOI18N
        lblContraseñaConfirmacion.setText(resourceMap.getString("lblContraseñaConfirmacion.text")); // NOI18N
        lblContraseñaConfirmacion.setName("lblContraseñaConfirmacion"); // NOI18N

        txtContrasenia1.setText(resourceMap.getString("txtContrasenia1.text")); // NOI18N
        txtContrasenia1.setName("txtContrasenia1"); // NOI18N

        txtContraseniaConfirmacion1.setText(resourceMap.getString("txtContraseniaConfirmacion1.text")); // NOI18N
        txtContraseniaConfirmacion1.setName("txtContraseniaConfirmacion1"); // NOI18N
        txtContraseniaConfirmacion1.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                txtContraseniaConfirmacion1KeyPressed(evt);
            }
            public void keyReleased(java.awt.event.KeyEvent evt) {
                txtContraseniaConfirmacion1KeyReleased(evt);
            }
        });

        javax.swing.GroupLayout panelRound1Layout = new javax.swing.GroupLayout(panelRound1);
        panelRound1.setLayout(panelRound1Layout);
        panelRound1Layout.setHorizontalGroup(
            panelRound1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelRound1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelRound1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel5)
                    .addComponent(jLabel4)
                    .addComponent(jLabel6))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(panelRound1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panelRound1Layout.createSequentialGroup()
                        .addComponent(lblContraseñaConfirmacion, javax.swing.GroupLayout.DEFAULT_SIZE, 248, Short.MAX_VALUE)
                        .addGap(56, 56, 56))
                    .addGroup(panelRound1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(txtContraseniaConfirmacion1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(txtContrasenia1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 103, Short.MAX_VALUE)
                        .addComponent(txtNombreUsuario, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 254, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(103, 103, 103))
        );
        panelRound1Layout.setVerticalGroup(
            panelRound1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelRound1Layout.createSequentialGroup()
                .addGap(21, 21, 21)
                .addGroup(panelRound1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(txtNombreUsuario, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panelRound1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(txtContrasenia1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGroup(panelRound1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panelRound1Layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel6)
                        .addGap(6, 6, 6))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelRound1Layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 6, Short.MAX_VALUE)
                        .addComponent(txtContraseniaConfirmacion1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
                .addComponent(lblContraseñaConfirmacion)
                .addContainerGap())
        );

        btnDisponibilidad.setText(resourceMap.getString("btnDisponibilidad.text")); // NOI18N
        btnDisponibilidad.setName("btnDisponibilidad"); // NOI18N
        btnDisponibilidad.setOpaque(false);
        btnDisponibilidad.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnDisponibilidadActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout panelImage3Layout = new javax.swing.GroupLayout(panelImage3);
        panelImage3.setLayout(panelImage3Layout);
        panelImage3Layout.setHorizontalGroup(
            panelImage3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelImage3Layout.createSequentialGroup()
                .addGap(23, 23, 23)
                .addComponent(panelRound1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(23, 23, 23))
            .addGroup(panelImage3Layout.createSequentialGroup()
                .addGap(230, 230, 230)
                .addComponent(btnDisponibilidad)
                .addContainerGap(276, Short.MAX_VALUE))
        );
        panelImage3Layout.setVerticalGroup(
            panelImage3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelImage3Layout.createSequentialGroup()
                .addGap(140, 140, 140)
                .addComponent(panelRound1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnDisponibilidad)
                .addContainerGap(151, Short.MAX_VALUE))
        );

        tabbedPaneVertical1.addTab(resourceMap.getString("panelImage3.TabConstraints.tabTitle"), panelImage3); // NOI18N

        panelImage2.setIcon(resourceMap.getIcon("panelImage2.icon")); // NOI18N
        panelImage2.setName("panelImage2"); // NOI18N
        panelImage2.setOpaque(false);

        panelRound2.setName("panelRound2"); // NOI18N

        jLabel21.setFont(resourceMap.getFont("jLabel7.font")); // NOI18N
        jLabel21.setForeground(resourceMap.getColor("jLabel21.foreground")); // NOI18N
        jLabel21.setText(resourceMap.getString("jLabel21.text")); // NOI18N
        jLabel21.setName("jLabel21"); // NOI18N

        txtTituloAcademico.setName("txtTituloAcademico"); // NOI18N
        txtTituloAcademico.setOpaque(true);

        cbxEstadoLaboral.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "NOMBRAMIENTO", "CONTRATO_TIEMPO_COMPLETO", "CONTRATO_MEDIO_TIEMPO" }));
        cbxEstadoLaboral.setName("cbxEstadoLaboral"); // NOI18N
        cbxEstadoLaboral.setOpaque(false);
        cbxEstadoLaboral.setRequestFocusEnabled(false);

        jLabel22.setFont(resourceMap.getFont("jLabel7.font")); // NOI18N
        jLabel22.setForeground(resourceMap.getColor("jLabel22.foreground")); // NOI18N
        jLabel22.setText(resourceMap.getString("jLabel22.text")); // NOI18N
        jLabel22.setName("jLabel22"); // NOI18N

        javax.swing.GroupLayout panelRound2Layout = new javax.swing.GroupLayout(panelRound2);
        panelRound2.setLayout(panelRound2Layout);
        panelRound2Layout.setHorizontalGroup(
            panelRound2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelRound2Layout.createSequentialGroup()
                .addGap(29, 29, 29)
                .addGroup(panelRound2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel22)
                    .addComponent(jLabel21))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panelRound2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(cbxEstadoLaboral, javax.swing.GroupLayout.PREFERRED_SIZE, 214, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtTituloAcademico, javax.swing.GroupLayout.PREFERRED_SIZE, 422, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(23, 23, 23))
        );
        panelRound2Layout.setVerticalGroup(
            panelRound2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelRound2Layout.createSequentialGroup()
                .addContainerGap(28, Short.MAX_VALUE)
                .addGroup(panelRound2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel21)
                    .addComponent(txtTituloAcademico, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panelRound2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cbxEstadoLaboral, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel22))
                .addGap(26, 26, 26))
        );

        jLabel2.setFont(resourceMap.getFont("jLabel2.font")); // NOI18N
        jLabel2.setForeground(resourceMap.getColor("jLabel2.foreground")); // NOI18N
        jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
        jLabel2.setName("jLabel2"); // NOI18N

        panelRound3.setName("panelRound3"); // NOI18N

        txtNombres.setName("txtNombres"); // NOI18N
        txtNombres.setOpaque(true);

        cbxTipoDNI.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "DOCUMENTO_NACIONAL_IDENTIFICACION", "PASAPORTE" }));
        cbxTipoDNI.setName("cbxTipoDNI"); // NOI18N
        cbxTipoDNI.setOpaque(false);
        cbxTipoDNI.setRequestFocusEnabled(false);

        txtDNI.setName("txtDNI"); // NOI18N
        txtDNI.setOpaque(true);

        jLabel7.setFont(resourceMap.getFont("jLabel7.font")); // NOI18N
        jLabel7.setForeground(resourceMap.getColor("jLabel7.foreground")); // NOI18N
        jLabel7.setText(resourceMap.getString("jLabel7.text")); // NOI18N
        jLabel7.setName("jLabel7"); // NOI18N

        jLabel16.setFont(resourceMap.getFont("jLabel7.font")); // NOI18N
        jLabel16.setForeground(resourceMap.getColor("jLabel16.foreground")); // NOI18N
        jLabel16.setText(resourceMap.getString("jLabel16.text")); // NOI18N
        jLabel16.setName("jLabel16"); // NOI18N

        jLabel17.setFont(resourceMap.getFont("jLabel7.font")); // NOI18N
        jLabel17.setForeground(resourceMap.getColor("jLabel17.foreground")); // NOI18N
        jLabel17.setText(resourceMap.getString("jLabel17.text")); // NOI18N
        jLabel17.setName("jLabel17"); // NOI18N

        jLabel18.setFont(resourceMap.getFont("jLabel7.font")); // NOI18N
        jLabel18.setForeground(resourceMap.getColor("jLabel18.foreground")); // NOI18N
        jLabel18.setText(resourceMap.getString("jLabel18.text")); // NOI18N
        jLabel18.setName("jLabel18"); // NOI18N

        cbxGenero.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "MASCULINO", "FEMENINO" }));
        cbxGenero.setName("cbxGenero"); // NOI18N
        cbxGenero.setOpaque(false);
        cbxGenero.setRequestFocusEnabled(false);

        txtApellidos.setName("txtApellidos"); // NOI18N
        txtApellidos.setOpaque(true);

        jLabel19.setFont(resourceMap.getFont("jLabel7.font")); // NOI18N
        jLabel19.setForeground(resourceMap.getColor("jLabel19.foreground")); // NOI18N
        jLabel19.setText(resourceMap.getString("jLabel19.text")); // NOI18N
        jLabel19.setName("jLabel19"); // NOI18N

        jLabel20.setFont(resourceMap.getFont("jLabel7.font")); // NOI18N
        jLabel20.setForeground(resourceMap.getColor("jLabel20.foreground")); // NOI18N
        jLabel20.setText(resourceMap.getString("jLabel20.text")); // NOI18N
        jLabel20.setName("jLabel20"); // NOI18N

        jLabel23.setFont(resourceMap.getFont("jLabel7.font")); // NOI18N
        jLabel23.setForeground(resourceMap.getColor("jLabel23.foreground")); // NOI18N
        jLabel23.setText(resourceMap.getString("jLabel23.text")); // NOI18N
        jLabel23.setName("jLabel23"); // NOI18N

        txtEmail.setName("txtEmail"); // NOI18N
        txtEmail.setOpaque(true);

        jLabel24.setFont(resourceMap.getFont("jLabel7.font")); // NOI18N
        jLabel24.setForeground(resourceMap.getColor("jLabel24.foreground")); // NOI18N
        jLabel24.setText(resourceMap.getString("jLabel24.text")); // NOI18N
        jLabel24.setName("jLabel24"); // NOI18N

        cbxEstadoCivil.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "SOLTERO", "CASADO", "DIVORCIADO", "VIUDO", "UNION_LIBRE" }));
        cbxEstadoCivil.setName("cbxEstadoCivil"); // NOI18N
        cbxEstadoCivil.setOpaque(false);
        cbxEstadoCivil.setRequestFocusEnabled(false);

        dtcFechaNacimiento.setName("dtcFechaNacimiento"); // NOI18N
        dtcFechaNacimiento.setRequestFocusEnabled(false);

        javax.swing.GroupLayout panelRound3Layout = new javax.swing.GroupLayout(panelRound3);
        panelRound3.setLayout(panelRound3Layout);
        panelRound3Layout.setHorizontalGroup(
            panelRound3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelRound3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelRound3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel17)
                    .addComponent(jLabel16)
                    .addComponent(jLabel7)
                    .addComponent(jLabel18)
                    .addComponent(jLabel19)
                    .addComponent(jLabel24)
                    .addComponent(jLabel23)
                    .addComponent(jLabel20))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panelRound3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panelRound3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(txtNombres, javax.swing.GroupLayout.PREFERRED_SIZE, 259, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelRound3Layout.createSequentialGroup()
                            .addComponent(cbxGenero, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGap(267, 267, 267))
                        .addGroup(panelRound3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(dtcFechaNacimiento, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(txtDNI, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 145, Short.MAX_VALUE)))
                    .addComponent(txtEmail, javax.swing.GroupLayout.PREFERRED_SIZE, 259, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cbxEstadoCivil, javax.swing.GroupLayout.PREFERRED_SIZE, 174, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(panelRound3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(cbxTipoDNI, javax.swing.GroupLayout.Alignment.LEADING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(txtApellidos, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 259, Short.MAX_VALUE)))
                .addGap(155, 155, 155))
        );
        panelRound3Layout.setVerticalGroup(
            panelRound3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelRound3Layout.createSequentialGroup()
                .addGap(20, 20, 20)
                .addGroup(panelRound3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtNombres, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel7))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panelRound3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel16)
                    .addComponent(txtApellidos, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panelRound3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cbxTipoDNI, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel17))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panelRound3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel18)
                    .addComponent(txtDNI, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panelRound3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cbxGenero, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel19))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panelRound3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel20)
                    .addComponent(dtcFechaNacimiento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panelRound3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtEmail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel23))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panelRound3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cbxEstadoCivil, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel24))
                .addContainerGap(22, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout panelImage2Layout = new javax.swing.GroupLayout(panelImage2);
        panelImage2.setLayout(panelImage2Layout);
        panelImage2Layout.setHorizontalGroup(
            panelImage2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelImage2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelImage2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelImage2Layout.createSequentialGroup()
                        .addComponent(jLabel2)
                        .addGap(493, 493, 493))
                    .addGroup(panelImage2Layout.createSequentialGroup()
                        .addGroup(panelImage2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(panelRound3, javax.swing.GroupLayout.Alignment.LEADING, 0, 610, Short.MAX_VALUE)
                            .addComponent(panelRound2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 610, Short.MAX_VALUE))
                        .addContainerGap(25, Short.MAX_VALUE))))
        );
        panelImage2Layout.setVerticalGroup(
            panelImage2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelImage2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(panelRound3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(panelRound2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(38, Short.MAX_VALUE))
        );

        tabbedPaneVertical1.addTab(resourceMap.getString("panelImage2.TabConstraints.tabTitle"), panelImage2); // NOI18N

        panelImage5.setIcon(resourceMap.getIcon("panelImage5.icon")); // NOI18N
        panelImage5.setName("panelImage5"); // NOI18N

        panelRound4.setName("panelRound4"); // NOI18N

        txtPais.setName("txtPais"); // NOI18N
        txtPais.setOpaque(true);

        txtCiudad.setName("txtCiudad"); // NOI18N
        txtCiudad.setOpaque(true);

        jLabel8.setFont(resourceMap.getFont("jLabel8.font")); // NOI18N
        jLabel8.setForeground(resourceMap.getColor("jLabel8.foreground")); // NOI18N
        jLabel8.setText(resourceMap.getString("jLabel8.text")); // NOI18N
        jLabel8.setName("jLabel8"); // NOI18N

        jLabel9.setFont(resourceMap.getFont("jLabel8.font")); // NOI18N
        jLabel9.setForeground(resourceMap.getColor("jLabel9.foreground")); // NOI18N
        jLabel9.setText(resourceMap.getString("jLabel9.text")); // NOI18N
        jLabel9.setName("jLabel9"); // NOI18N

        jLabel10.setFont(resourceMap.getFont("jLabel8.font")); // NOI18N
        jLabel10.setForeground(resourceMap.getColor("jLabel10.foreground")); // NOI18N
        jLabel10.setText(resourceMap.getString("jLabel10.text")); // NOI18N
        jLabel10.setName("jLabel10"); // NOI18N

        txtProvincia.setName("txtProvincia"); // NOI18N
        txtProvincia.setOpaque(true);

        txtCelular.setName("txtCelular"); // NOI18N
        txtCelular.setOpaque(true);

        txtTelefono.setName("txtTelefono"); // NOI18N
        txtTelefono.setOpaque(true);

        txtNumeroConstruccion.setText(resourceMap.getString("txtNumeroConstruccion.text")); // NOI18N
        txtNumeroConstruccion.setName("txtNumeroConstruccion"); // NOI18N
        txtNumeroConstruccion.setOpaque(true);

        jLabel11.setFont(resourceMap.getFont("jLabel8.font")); // NOI18N
        jLabel11.setForeground(resourceMap.getColor("jLabel11.foreground")); // NOI18N
        jLabel11.setText(resourceMap.getString("jLabel11.text")); // NOI18N
        jLabel11.setName("jLabel11"); // NOI18N

        jLabel13.setFont(resourceMap.getFont("jLabel8.font")); // NOI18N
        jLabel13.setForeground(resourceMap.getColor("jLabel13.foreground")); // NOI18N
        jLabel13.setText(resourceMap.getString("jLabel13.text")); // NOI18N
        jLabel13.setName("jLabel13"); // NOI18N

        jLabel14.setFont(resourceMap.getFont("jLabel8.font")); // NOI18N
        jLabel14.setForeground(resourceMap.getColor("jLabel14.foreground")); // NOI18N
        jLabel14.setText(resourceMap.getString("jLabel14.text")); // NOI18N
        jLabel14.setName("jLabel14"); // NOI18N

        jLabel15.setFont(resourceMap.getFont("jLabel8.font")); // NOI18N
        jLabel15.setForeground(resourceMap.getColor("jLabel15.foreground")); // NOI18N
        jLabel15.setText(resourceMap.getString("jLabel15.text")); // NOI18N
        jLabel15.setName("jLabel15"); // NOI18N

        jScrollPane2.setName("jScrollPane2"); // NOI18N

        txtObservaciones.setColumns(20);
        txtObservaciones.setRows(5);
        txtObservaciones.setName("txtObservaciones"); // NOI18N
        jScrollPane2.setViewportView(txtObservaciones);

        txtCalles.setName("txtCalles"); // NOI18N
        txtCalles.setOpaque(true);

        jLabel12.setFont(resourceMap.getFont("jLabel8.font")); // NOI18N
        jLabel12.setForeground(resourceMap.getColor("jLabel12.foreground")); // NOI18N
        jLabel12.setText(resourceMap.getString("jLabel12.text")); // NOI18N
        jLabel12.setName("jLabel12"); // NOI18N

        javax.swing.GroupLayout panelRound4Layout = new javax.swing.GroupLayout(panelRound4);
        panelRound4.setLayout(panelRound4Layout);
        panelRound4Layout.setHorizontalGroup(
            panelRound4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelRound4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelRound4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(panelRound4Layout.createSequentialGroup()
                        .addGroup(panelRound4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel12)
                            .addComponent(jLabel10)
                            .addComponent(jLabel9)
                            .addComponent(jLabel8))
                        .addGap(6, 6, 6))
                    .addGroup(panelRound4Layout.createSequentialGroup()
                        .addGroup(panelRound4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel15)
                            .addComponent(jLabel14)
                            .addComponent(jLabel13))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
                    .addGroup(panelRound4Layout.createSequentialGroup()
                        .addComponent(jLabel11)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
                .addGroup(panelRound4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jScrollPane2)
                    .addComponent(txtCelular, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(txtTelefono, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(txtNumeroConstruccion, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(txtCalles, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(txtProvincia, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(txtCiudad, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(txtPais, javax.swing.GroupLayout.DEFAULT_SIZE, 276, Short.MAX_VALUE))
                .addContainerGap(60, Short.MAX_VALUE))
        );
        panelRound4Layout.setVerticalGroup(
            panelRound4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelRound4Layout.createSequentialGroup()
                .addGap(21, 21, 21)
                .addGroup(panelRound4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtPais, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel8))
                .addGap(8, 8, 8)
                .addGroup(panelRound4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtCiudad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel9))
                .addGap(8, 8, 8)
                .addGroup(panelRound4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtProvincia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel10))
                .addGap(7, 7, 7)
                .addGroup(panelRound4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtCalles, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel12))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 11, Short.MAX_VALUE)
                .addGroup(panelRound4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtNumeroConstruccion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel11))
                .addGap(8, 8, 8)
                .addGroup(panelRound4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtTelefono, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel13))
                .addGap(8, 8, 8)
                .addGroup(panelRound4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtCelular, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel14))
                .addGap(9, 9, 9)
                .addGroup(panelRound4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel15)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(20, 20, 20))
        );

        javax.swing.GroupLayout panelImage5Layout = new javax.swing.GroupLayout(panelImage5);
        panelImage5.setLayout(panelImage5Layout);
        panelImage5Layout.setHorizontalGroup(
            panelImage5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelImage5Layout.createSequentialGroup()
                .addContainerGap(110, Short.MAX_VALUE)
                .addComponent(panelRound4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(99, 99, 99))
        );
        panelImage5Layout.setVerticalGroup(
            panelImage5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelImage5Layout.createSequentialGroup()
                .addGap(42, 42, 42)
                .addComponent(panelRound4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(55, Short.MAX_VALUE))
        );

        tabbedPaneVertical1.addTab(resourceMap.getString("panelImage5.TabConstraints.tabTitle"), panelImage5); // NOI18N

        panelImage4.setIcon(resourceMap.getIcon("panelImage4.icon")); // NOI18N
        panelImage4.setName("panelImage4"); // NOI18N

        jScrollPane5.setName("jScrollPane5"); // NOI18N

        lstRolesDisponibles.setFont(resourceMap.getFont("lstRolesDisponibles.font")); // NOI18N
        lstRolesDisponibles.setName("lstRolesDisponibles"); // NOI18N
        jScrollPane5.setViewportView(lstRolesDisponibles);

        jScrollPane6.setName("jScrollPane6"); // NOI18N

        lstRolesUsuario.setFont(resourceMap.getFont("lstRolesDisponibles.font")); // NOI18N
        lstRolesUsuario.setName("lstRolesUsuario"); // NOI18N

        org.jdesktop.beansbinding.ELProperty eLProperty = org.jdesktop.beansbinding.ELProperty.create("${rol.nombre}");
        org.jdesktop.swingbinding.JListBinding jListBinding = org.jdesktop.swingbinding.SwingBindings.createJListBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, lstRolesDisponibles, eLProperty, lstRolesUsuario);
        bindingGroup.addBinding(jListBinding);

        jScrollPane6.setViewportView(lstRolesUsuario);

        jLabel27.setFont(resourceMap.getFont("jLabel28.font")); // NOI18N
        jLabel27.setForeground(resourceMap.getColor("jLabel27.foreground")); // NOI18N
        jLabel27.setText(resourceMap.getString("jLabel27.text")); // NOI18N
        jLabel27.setName("jLabel27"); // NOI18N

        jLabel28.setFont(resourceMap.getFont("jLabel28.font")); // NOI18N
        jLabel28.setForeground(resourceMap.getColor("jLabel27.foreground")); // NOI18N
        jLabel28.setText(resourceMap.getString("jLabel28.text")); // NOI18N
        jLabel28.setName("jLabel28"); // NOI18N

        btnAgregar.setText(resourceMap.getString("btnAgregar.text")); // NOI18N
        btnAgregar.setName("btnAgregar"); // NOI18N
        btnAgregar.setOpaque(false);
        btnAgregar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAgregarActionPerformed(evt);
            }
        });

        btnRemover.setText(resourceMap.getString("btnRemover.text")); // NOI18N
        btnRemover.setName("btnRemover"); // NOI18N
        btnRemover.setOpaque(false);
        btnRemover.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnRemoverActionPerformed(evt);
            }
        });

        jScrollPane1.setName("jScrollPane1"); // NOI18N

        txtDescripcion.setColumns(20);
        txtDescripcion.setLineWrap(true);
        txtDescripcion.setRows(5);
        txtDescripcion.setText(resourceMap.getString("txtDescripcion.text")); // NOI18N
        txtDescripcion.setWrapStyleWord(true);
        txtDescripcion.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("txtDescripcion.border.title"))); // NOI18N
        txtDescripcion.setName("txtDescripcion"); // NOI18N
        jScrollPane1.setViewportView(txtDescripcion);

        javax.swing.GroupLayout panelImage4Layout = new javax.swing.GroupLayout(panelImage4);
        panelImage4.setLayout(panelImage4Layout);
        panelImage4Layout.setHorizontalGroup(
            panelImage4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelImage4Layout.createSequentialGroup()
                .addGap(82, 82, 82)
                .addGroup(panelImage4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelImage4Layout.createSequentialGroup()
                        .addGap(25, 25, 25)
                        .addComponent(jLabel27)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 174, Short.MAX_VALUE)
                        .addComponent(jLabel28)
                        .addGap(28, 28, 28))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelImage4Layout.createSequentialGroup()
                        .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(panelImage4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(btnAgregar, javax.swing.GroupLayout.DEFAULT_SIZE, 75, Short.MAX_VALUE)
                            .addComponent(btnRemover, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, 191, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(81, 81, 81))
            .addGroup(panelImage4Layout.createSequentialGroup()
                .addGap(179, 179, 179)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 298, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(168, Short.MAX_VALUE))
        );
        panelImage4Layout.setVerticalGroup(
            panelImage4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelImage4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelImage4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel28)
                    .addComponent(jLabel27))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panelImage4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panelImage4Layout.createSequentialGroup()
                        .addGap(95, 95, 95)
                        .addComponent(btnAgregar)
                        .addGap(44, 44, 44)
                        .addComponent(btnRemover))
                    .addGroup(panelImage4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(jScrollPane6, javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jScrollPane5, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 279, Short.MAX_VALUE)))
                .addGap(17, 17, 17)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 110, Short.MAX_VALUE)
                .addContainerGap())
        );

        tabbedPaneVertical1.addTab(resourceMap.getString("panelImage4.TabConstraints.tabTitle"), panelImage4); // NOI18N

        btnGuardar.setText(resourceMap.getString("btnGuardar.text")); // NOI18N
        btnGuardar.setName("btnGuardar"); // NOI18N
        btnGuardar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnGuardarActionPerformed(evt);
            }
        });

        btnCancelar.setText(resourceMap.getString("btnCancelar.text")); // NOI18N
        btnCancelar.setName("btnCancelar"); // NOI18N
        btnCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCancelarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(tabbedPaneVertical1, javax.swing.GroupLayout.PREFERRED_SIZE, 645, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(btnGuardar, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(382, 382, 382)
                .addComponent(btnCancelar, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(tabbedPaneVertical1, javax.swing.GroupLayout.PREFERRED_SIZE, 490, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnGuardar)
                    .addComponent(btnCancelar))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        bindingGroup.bind();

        pack();
    }// </editor-fold>//GEN-END:initComponents

private void btnDisponibilidadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDisponibilidadActionPerformed
    if (usuarioUCC.disponibilidad(txtNombreUsuario.getText()) == true) {
        JOptionPane.showMessageDialog(this, "Nick disponible");
    } else {
        JOptionPane.showMessageDialog(this, "Ya existe otro Usuario con el mismo Nombre de Usuario");
    }
}//GEN-LAST:event_btnDisponibilidadActionPerformed

private void btnAgregarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAgregarActionPerformed
//    try {
    if (lstRolesDisponibles.getSelectedValue().toString().isEmpty() == false) {
        usuarioUCC.setRol(lstRolesDisponibles.getSelectedValue() + "");
        rolesUsuario.addElement(lstRolesDisponibles.getSelectedValue());
        lstRolesUsuario.setModel(rolesUsuario);
        rolesDisponibles.removeElement(lstRolesDisponibles.getSelectedValue());
        lstRolesDisponibles.setModel(rolesDisponibles);
        btnAgregar.setEnabled(false);
        btnRemover.setEnabled(true);
    }
    // } catch (NullPointerException e) {
    // }
}//GEN-LAST:event_btnAgregarActionPerformed

private void btnRemoverActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRemoverActionPerformed
    try {
        if (lstRolesUsuario.getSelectedValue().toString().isEmpty() == false) {
            rolesDisponibles.addElement(lstRolesUsuario.getSelectedValue());
            lstRolesDisponibles.setModel(rolesDisponibles);
            rolesUsuario.removeElement(lstRolesUsuario.getSelectedValue());
            lstRolesUsuario.setModel(rolesUsuario);
            usuarioUCC.setRol("");
            btnAgregar.setEnabled(true);
            btnRemover.setEnabled(false);
        }
    } catch (NullPointerException e) {
    }

}//GEN-LAST:event_btnRemoverActionPerformed

private void btnCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelarActionPerformed
    this.dispose();
    BuscarUsuario buscar = new BuscarUsuario();
    buscar.setVisible(true);
}//GEN-LAST:event_btnCancelarActionPerformed

private void btnGuardarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGuardarActionPerformed
   if (rolesUsuario.size() == 1) {
       if (contraseñaCorrecta == true) {
            if (camposObligatoriosVacios() == false) {
                if (validarDNI() == true) {
                    guardarDatos();
                    if (editar == false) {
                        if (usuarioUCC.existe(usuarioUCC.getUsuario()) == false) {
                            usuarioUCC.guardar(usuarioUCC.getUsuario());
                            this.dispose();
                            JOptionPane.showMessageDialog(this, "Usuario guardado");
                            BuscarUsuario buscar = new BuscarUsuario();
                            buscar.setVisible(true);
                        } else {
                            JOptionPane.showMessageDialog(this, "Usuario ya existe:\n\tEl número de identificación ya hace referencia a otra persona");
                        }
                    } else {
                        usuarioUCC.actualizar(usuarioUCC.getUsuario());
                        JOptionPane.showMessageDialog(this, "Usuario guardado");
                        this.dispose();
                        BuscarUsuario buscar = new BuscarUsuario();
                        buscar.setVisible(true);
                    }
                } else {
                    JOptionPane.showMessageDialog(this, "DNI Incorrecto");
                }
            } else {
                this.setVisible(false);
                JOptionPane.showMessageDialog(this, "Campos Oblibatorios Vacíos");
                this.setVisible(true);
            }
        } else {
            JOptionPane.showMessageDialog(this, "Contraseña Incorrecta");
        }
    } else {
        JOptionPane.showMessageDialog(this, "El Usuario debe tener asignado un rol.");
    }
}//GEN-LAST:event_btnGuardarActionPerformed

private void txtContraseniaConfirmacion1KeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtContraseniaConfirmacion1KeyPressed
    if (txtContrasenia1.getText().equals(txtContraseniaConfirmacion1.getText().toString())) {
        lblContraseñaConfirmacion.setForeground(Color.green);
        lblContraseñaConfirmacion.setText("Contraseña correcta");
        contraseñaCorrecta = true;
    } else {
        lblContraseñaConfirmacion.setForeground(Color.red);
        lblContraseñaConfirmacion.setText("Las Contraseñas no coinciden");
        contraseñaCorrecta = false;
    }
}//GEN-LAST:event_txtContraseniaConfirmacion1KeyPressed

private void txtContraseniaConfirmacion1KeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtContraseniaConfirmacion1KeyReleased
    if (txtContrasenia1.getText().equals(txtContraseniaConfirmacion1.getText().toString())) {
        lblContraseñaConfirmacion.setForeground(Color.green);
        lblContraseñaConfirmacion.setText("Contraseña correcta");
        contraseñaCorrecta = true;
    } else {
        lblContraseñaConfirmacion.setForeground(Color.red);
        lblContraseñaConfirmacion.setText("Las Contraseñas no coinciden");
        contraseñaCorrecta = false;
    }
}//GEN-LAST:event_txtContraseniaConfirmacion1KeyReleased
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnAgregar;
    private javax.swing.JButton btnCancelar;
    private javax.swing.JButton btnDisponibilidad;
    private javax.swing.JButton btnGuardar;
    private javax.swing.JButton btnRemover;
    private javax.swing.JComboBox cbxEstadoCivil;
    private javax.swing.JComboBox cbxEstadoLaboral;
    private javax.swing.JComboBox cbxGenero;
    private javax.swing.JComboBox cbxTipoDNI;
    private com.toedter.calendar.JDateChooser dtcFechaNacimiento;
    private javax.swing.JComboBox jComboBox1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel27;
    private javax.swing.JLabel jLabel28;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JScrollPane jScrollPane6;
    private javax.swing.JLabel lblContraseñaConfirmacion;
    private javax.swing.JList lstRolesDisponibles;
    private javax.swing.JList lstRolesUsuario;
    private org.edisoncor.gui.panel.PanelImage panelImage2;
    private org.edisoncor.gui.panel.PanelImage panelImage3;
    private org.edisoncor.gui.panel.PanelImage panelImage4;
    private org.edisoncor.gui.panel.PanelImage panelImage5;
    private org.edisoncor.gui.panel.PanelRound panelRound1;
    private org.edisoncor.gui.panel.PanelRound panelRound2;
    private org.edisoncor.gui.panel.PanelRound panelRound3;
    private org.edisoncor.gui.panel.PanelRound panelRound4;
    private org.edisoncor.gui.tabbedPane.TabbedPaneVertical tabbedPaneVertical1;
    private org.edisoncor.gui.textField.TextFieldRound txtApellidos;
    private org.edisoncor.gui.textField.TextFieldRound txtCalles;
    private org.edisoncor.gui.textField.TextFieldRound txtCelular;
    private org.edisoncor.gui.textField.TextFieldRound txtCiudad;
    private org.edisoncor.gui.passwordField.PasswordFieldRound txtContrasenia1;
    private org.edisoncor.gui.passwordField.PasswordFieldRound txtContraseniaConfirmacion1;
    private org.edisoncor.gui.textField.TextFieldRound txtDNI;
    private javax.swing.JTextArea txtDescripcion;
    private org.edisoncor.gui.textField.TextFieldRound txtEmail;
    private org.edisoncor.gui.textField.TextFieldRound txtNombreUsuario;
    private org.edisoncor.gui.textField.TextFieldRound txtNombres;
    private org.edisoncor.gui.textField.TextFieldRound txtNumeroConstruccion;
    private javax.swing.JTextArea txtObservaciones;
    private org.edisoncor.gui.textField.TextFieldRound txtPais;
    private org.edisoncor.gui.textField.TextFieldRound txtProvincia;
    private org.edisoncor.gui.textField.TextFieldRound txtTelefono;
    private org.edisoncor.gui.textField.TextFieldRound txtTituloAcademico;
    private org.jdesktop.beansbinding.BindingGroup bindingGroup;
    // End of variables declaration//GEN-END:variables

    public void reemplazarCampos(Usuario usuario) {
        txtNombres.setText(usuario.getNombres());
        txtContraseniaConfirmacion1.setText(usuario.getContrasenia());
        txtApellidos.setText(usuario.getApellidos());
        cbxTipoDNI.setSelectedItem(usuario.getM_TipoDocumentoIdentificacion().toString());
        txtDNI.setText(usuario.getNumeroDocumentoIdentificacion());
        cbxGenero.setSelectedItem(usuario.getM_TipoGenero().toString());
        dtcFechaNacimiento.setDate(usuario.getFechaNacimiento());
        txtEmail.setText(usuario.getE_mail());
        cbxEstadoCivil.setSelectedItem(usuario.getM_EstadoCivil().toString());
        txtNombreUsuario.setText(usuario.getNick());
        txtContrasenia1.setText(usuario.getContrasenia());
        txtPais.setText(usuario.getDireccion().getPais());
        txtCiudad.setText(usuario.getDireccion().getCiudad());
        txtProvincia.setText(usuario.getDireccion().getProvincia());
        txtNumeroConstruccion.setText(usuario.getDireccion().getNumeroConstruccion() + "");
        txtTelefono.setText(usuario.getDireccion().getTelefono());
        txtCelular.setText(usuario.getDireccion().getCelular());
        txtObservaciones.setText(usuario.getDireccion().getObservacion());
        txtCalles.setText(usuario.getDireccion().getCalles());
        txtTituloAcademico.setText(usuario.getTitulo());
        txtDNI.setEditable(false);
    }

    public void cargarRoles(boolean editar) {
        DefaultListModel roles = new DefaultListModel();
        DefaultListModel roles2 = new DefaultListModel();
        roles.clear();
        roles2.clear();
        rolesUsuario.clear();
        rolesDisponibles.clear();
        lstRolesDisponibles.clearSelection();
        lstRolesUsuario.clearSelection();
        if (editar == true) {
            roles.addElement(usuarioUCC.getUsuario().getRol().getNombre());
            rolesUsuario.addElement(usuarioUCC.getUsuario().getRol().getNombre());
            lstRolesUsuario.setModel(roles);
            for (Rol rol : usuarioUCC.roles()) {
                if (rol.getNombre().equals(usuarioUCC.getUsuario().getRol().getNombre()) == false) {
                    roles2.addElement(rol.getNombre());
                    rolesDisponibles.addElement(rol.getNombre());
                    lstRolesDisponibles.setModel(roles2);
                }
            }
            btnAgregar.setEnabled(false);
            btnRemover.setEnabled(true);
        } else {
            for (Rol rol : usuarioUCC.roles()) {
                roles.addElement(rol.getNombre());
                rolesDisponibles.addElement(rol.getNombre());
                lstRolesDisponibles.setModel(roles);
            }
        }
    }

    private boolean camposObligatoriosVacios() {
        boolean campos = false;
        try {
            Integer.parseInt(txtNumeroConstruccion.getText());
            if (txtNombreUsuario.getText().isEmpty() || txtContrasenia1.getText().isEmpty() || txtNombres.getText().isEmpty() || txtApellidos.getText().isEmpty() || txtDNI.getText().isEmpty() || txtTituloAcademico.getText().isEmpty()) {
                campos = true;
            }
        } catch (NumberFormatException e) {
            JOptionPane.showMessageDialog(this, "El número de casa debe tener el siguiente formato: 0516");
            campos = true;
        } catch (StringIndexOutOfBoundsException e) {
            campos = true;
        }
        return campos;
    }

    private boolean validarDNI() {
        boolean validar = true;
        if (cbxTipoDNI.getSelectedIndex() == 0) {
            usuarioUCC.getUsuario().setNumeroDocumentoIdentificacion(txtDNI.getText());
            if (usuarioUCC.getUsuario().validarDNI() == false) {
                validar = false;
            }
        }
        return validar;
    }

    private void guardarDatos() {
        usuarioUCC.getUsuario().setNick(txtNombreUsuario.getText());
        usuarioUCC.getUsuario().setContrasenia(txtContrasenia1.getText().toString());
        usuarioUCC.getUsuario().setNombres(txtNombres.getText().toUpperCase());
        usuarioUCC.getUsuario().setApellidos(txtApellidos.getText().toUpperCase());
        usuarioUCC.getUsuario().setM_TipoDocumentoIdentificacion(TipoDocumentoIdentificacion.valueOf(cbxTipoDNI.getSelectedItem().toString()));
        usuarioUCC.getUsuario().setNumeroDocumentoIdentificacion(txtDNI.getText());
        usuarioUCC.getUsuario().setM_TipoGenero(TipoGenero.valueOf(cbxGenero.getSelectedItem().toString()));
        usuarioUCC.getUsuario().setFechaNacimiento(dtcFechaNacimiento.getDate());
        usuarioUCC.getUsuario().setE_mail(txtEmail.getText().toUpperCase());
        usuarioUCC.getUsuario().setM_EstadoCivil(EstadoCivil.valueOf(cbxEstadoCivil.getSelectedItem().toString()));
        usuarioUCC.getUsuario().setTitulo(txtTituloAcademico.getText().toUpperCase());
        usuarioUCC.getUsuario().setM_estadoLaboral(EstadoLaboral.valueOf(cbxEstadoLaboral.getSelectedItem().toString()));
        if (editar == false) {
            usuarioUCC.getUsuario().setDireccion(new Direccion());
        }
        usuarioUCC.getUsuario().getDireccion().setPais(txtPais.getText().toUpperCase());
        usuarioUCC.getUsuario().getDireccion().setCiudad(txtCiudad.getText().toUpperCase());
        usuarioUCC.getUsuario().getDireccion().setProvincia(txtProvincia.getText().toUpperCase());
        usuarioUCC.getUsuario().getDireccion().setNumeroConstruccion(Integer.parseInt(txtNumeroConstruccion.getText()));
        usuarioUCC.getUsuario().getDireccion().setTelefono(txtTelefono.getText());
        usuarioUCC.getUsuario().getDireccion().setCelular(txtCelular.getText());
        usuarioUCC.getUsuario().getDireccion().setObservacion(txtObservaciones.getText().toUpperCase());
        usuarioUCC.getUsuario().getDireccion().setCalles(txtCalles.getText().toUpperCase());
        for (Rol r : usuarioUCC.roles()) {
            if (r.getNombre().equals(usuarioUCC.getRol())) {
                usuarioUCC.getUsuario().setRol(r);
            }
        }

    }
}
